package com.ruoyi.hotel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HotelRoomChange;
import com.ruoyi.hotel.service.IHotelRoomChangeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店房间变动Controller
 *
 * @author iis
 * @date 2024-03-30
 */
@RestController
@RequestMapping("/hotel/roomChange")
public class HotelRoomChangeController extends BaseController
{
    @Autowired
    private IHotelRoomChangeService hotelRoomChangeService;

    /**
     * 查询酒店房间变动列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:roomChange:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelRoomChange hotelRoomChange)
    {
        startPage();
        List<HotelRoomChange> list = hotelRoomChangeService.selectHotelRoomChangeList(hotelRoomChange);
        return getDataTable(list);
    }



    /**
     * 查询酒店房间变动列表
     */
//    @PreAuthorize("@ss.hasPermi('hotel:roomChange:list')")
    @GetMapping("/selectHotelRoomChangeList")
    public TableDataInfo selectHotelRoomChangeList(HotelRoomChange hotelRoomChange)
    {
        startPage();
        List<HotelRoomChange> list = hotelRoomChangeService.selectHotelRoomChangeList(hotelRoomChange);
        return getDataTable(list);
    }


    /**
     * 导出酒店房间变动列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:roomChange:export')")
    @Log(title = "酒店房间变动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelRoomChange hotelRoomChange)
    {
        List<HotelRoomChange> list = hotelRoomChangeService.selectHotelRoomChangeList(hotelRoomChange);
        ExcelUtil<HotelRoomChange> util = new ExcelUtil<HotelRoomChange>(HotelRoomChange.class);
        util.exportExcel(response, list, "酒店房间变动数据");
    }

    /**
     * 获取酒店房间变动详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:roomChange:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hotelRoomChangeService.selectHotelRoomChangeById(id));
    }

    /**
     * 新增酒店房间变动
     */
    @PreAuthorize("@ss.hasPermi('hotel:roomChange:add')")
    @Log(title = "酒店房间变动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelRoomChange hotelRoomChange)
    {
        return toAjax(hotelRoomChangeService.insertHotelRoomChange(hotelRoomChange));
    }

    /**
     * 修改酒店房间变动
     */
    @PreAuthorize("@ss.hasPermi('hotel:roomChange:edit')")
    @Log(title = "酒店房间变动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelRoomChange hotelRoomChange)
    {
        return toAjax(hotelRoomChangeService.updateHotelRoomChange(hotelRoomChange));
    }

    /**
     * 删除酒店房间变动
     */
    @PreAuthorize("@ss.hasPermi('hotel:roomChange:remove')")
    @Log(title = "酒店房间变动", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hotelRoomChangeService.deleteHotelRoomChangeByIds(ids));
    }
}
